package com.fesine.quartz.chapter14;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.util.Date;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/11/20 21:32
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/20 21:32
 */
public class Listing_14_2 {
    public static void main(String[] args) {
        new Listing_14_2().run();
    }

    public void run() {
        try {
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
            JobDetail jobDetail = new JobDetail(FirstJob.class.getSimpleName(), null, FirstJob
                    .class);
            JobDataMap jobDataMap = new JobDataMap();
            jobDataMap.put("nextJob", SecondJob.class.getName());
            jobDetail.setJobDataMap(jobDataMap);
            Trigger trigger = TriggerUtils.makeImmediateTrigger(0, 0);
            trigger.setName(FirstJob.class.getSimpleName());
            trigger.setStartTime(new Date());
            scheduler.scheduleJob(jobDetail, trigger);
            scheduler.start();

        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }

}
